package com.game.centerserver.infrastructure.service.impl;

import com.game.centerserver.infrastructure.entity.Archive;
import com.game.centerserver.infrastructure.dao.ArchiveDao;
import com.game.centerserver.infrastructure.service.ArchiveService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (Archive)表服务实现类
 *
 * @author makejava
 * @since 2024-11-14 23:07:46
 */
@Service("archiveService")
public class ArchiveServiceImpl implements ArchiveService {
    @Resource
    private ArchiveDao archiveDao;

    /**
     * 通过ID查询单条数据
     *
     * @param archiveId 主键
     * @return 实例对象
     */
    @Override
    public Archive queryById(String archiveId) {
        return this.archiveDao.queryById(archiveId);
    }

    /**
     * 新增数据
     *
     * @param archive 实例对象
     * @return 实例对象
     */
    @Override
    public boolean insert(Archive archive) {
        return this.archiveDao.insert(archive) > 0;
    }

    /**
     * 修改数据
     *
     * @param archive 实例对象
     * @return 实例对象
     */
    @Override
    public boolean update(Archive archive) {
        return this.archiveDao.update(archive) > 0;
    }

    /**
     * 通过主键删除数据
     *
     * @param archiveId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String archiveId) {
        return this.archiveDao.deleteById(archiveId) > 0;
    }

    @Override
    public List<Archive> queryByUid(String uid) {
        if (uid == null) return List.of();
        Archive queryArchive = new Archive();
        queryArchive.setUid(uid);
        return this.archiveDao.query(queryArchive);
    }
}
